<template>
	<view class="container">
		<view class="top-title">{{village_name}}访客通行证</view>
		<view class="top-text">{{village_name}}</view>
		<image :src="qrcode" mode="" class="QRcode-img"></image>
		<button type="primary" class="btn1" @tap="goQRvisitor">生成通行证</button>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const getvisitorList = () => {
		common.post('HouseApi&a=visitor_list', {
			village_id: _this.village_id,
			pigcms_id: _this.pigcms_id,
			page: 1,
		}, data => {
			console.log('++++', data)
			_this.listdata = data;
			_this.dataList = data.dataList;
		});
	};
	const getconfirmPass = () => {
		common.post('HouseApi&a=chk_visitor_info', {
			village_id: _this.village_id,
			pigcms_id: _this.pigcms_id,
			id: _this.id,
		}, data => {
			console.log('++++', data)
			getvisitorList();
			uni.navigateTo({
				url:'/pages/village/my/visitorRegistrationlist'
			})
		});
	};
	
	export default {
		data() {
			return {
				listdata: {},
				dataList:[],
				village_id: 0,
				pigcms_id: 0,
				village_name:'',
				actcolor: '',
				btn_style: '',
				mobile_head_color: '',
				id:0,
				isFirstLoad:true,
				list:[
					{
						name: '先生',
					},
					{
						name: '女士',
					}
				],
				num: 0,
				qrcode: '',
				visitor_id: '',
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
			if(_this.isFirstLoad == false){
				getvisitorList();
			}
		},
		onLoad(options) {
			_this = this;
			_this.qrcode = decodeURIComponent(options.qrcode)
			_this.visitor_id = options.visitor_id;
			console.log("3333333333333",_this.qrcode)
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.mobile_head_color = config.config.mobile_head_color
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				// getvisitorList()
				// _this.isFirstLoad = false;
			});
		},
		methods: {
			goQRvisitor(){
				uni.navigateTo({
					url:'/pages/village/my/shareVisitor?visitor_id=' + _this.visitor_id
				})
			},
		},
		components: {
			
		}
	}
</script>

<style>
	page {
		background: rgb(245, 245, 245);
	}

	.container {
		margin: 0;
		padding: 0;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.top-title {
		margin-top: 150rpx;
		font-size: 32rpx;
		font-weight: 700;
	}
	.top-text {
		margin-top: 15rpx;
		font-size: 32rpx;
		color: #CCCCCC;
	}
	.QRcode-img {
		width: 500rpx;
		height: 500rpx;
		display: block;
		margin-top: 150rpx;
	}
	.btn1 {
		width: 80%;
		margin-top: 150rpx;
		border-radius: 60rpx;
	}
</style>
